<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        main {
            background: yellow;

            height: 400px;
            width: 400px;
            margin: 20px;


            position: relative;

            /* 可拖拽调整大小 */
            resize: vertical;
            overflow: auto;
        }

        main div {
            position: absolute;
            left: 0;
            background: greenyellow;
            color: black;

            border: 2px solid black;

            /* 核心 */
            top: 50%;
            height: 100px;
            margin-top: -50px;

        }
    </style>
</head>
<body>
<main>
    <div>
        测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试
    </div>
</main>
</body>
</html>